package cn.iocoder.yudao.framework.websocket.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * WebSocket 配置项
 *
 * @author xingyu4j
 */
@ConfigurationProperties("yudao.websocket")
@Data
@Validated
public class WebSocketProperties {

    /**
     * WebSocket 的连接路径
     */
    @NotEmpty(message = "WebSocket 的连接路径不能为空")
    private String path = "/ws";

    /**
     * 消息发送器的类型
     *
     * 可选值：local、redis、rocketmq、kafka、rabbitmq
     */
    @NotNull(message = "WebSocket 的消息发送者不能为空")
    private String senderType = "local";

    /**
     * WebSocket 开关
     */
    private Boolean enable;

    /**
     * RocketMQ 相关配置
     */
    private SenderRocketmq senderRocketmq;

    /**
     * RabbitMQ 相关配置
     */
    private SenderRabbitmq senderRabbitmq;

    /**
     * Kafka 相关配置
     */
    private SenderKafka senderKafka;

    @Data
    public static class SenderRocketmq {
        /**
         * 消息发送的 RocketMQ Topic
         */
        private String topic;
        /**
         * 消息发送的 RocketMQ Consumer Group
         */
        private String consumerGroup;
    }

    @Data
    public static class SenderRabbitmq {
        /**
         * 消息发送的 RabbitMQ Exchange
         */
        private String exchange;
        /**
         * 消息发送的 RabbitMQ Queue
         */
        private String queue;
    }

    @Data
    public static class SenderKafka {
        /**
         * 消息发送的 Kafka Topic
         */
        private String topic;
    }
}